package com.itcs.app.tran;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.Resource;

import com.itcs.box.BoxConstants;
import com.itcs.box.domain.BoxResponse;
import com.itcs.dubbo.service.DubboService;

/**
 * @ClassName: Send2BoxThread
 * @Description: 向盒子推送消息
 * @author CHEN-HF
 * @date 2017年12月22日 下午4:28:29
 * 
 */
public class Send2BoxThread extends Thread {

	private BoxResponse boxResponse;

	private DubboService itcsBoxServer;

	public Send2BoxThread(DubboService itcsBoxServer, BoxResponse boxResponse) {
		this.itcsBoxServer = itcsBoxServer;
		this.boxResponse = boxResponse;
	}

	@Override
	public void run() {
		Map<String, Object> reqRecord = new HashMap<>();
		try {
			String messageType = boxResponse.getMessgeType();
			String tranId = "cbox_" + messageType;
			reqRecord.put(BoxConstants.BOX_REQ_KEY, boxResponse);
			Map<String, Object> resMap = itcsBoxServer.exchange(tranId, reqRecord);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
